package com.club.football.common;

import lombok.Data;

/**
 * 业务例外
 *
 * @author 1
 * @date 2024/01/22
 */
@Data
public class BusinessException extends RuntimeException {
    private static final long serialVersionUID = -810284859715336800L;
    /**
     * 编码
     */
    private Integer code;
    /**
     * 数据
     */
    private String data;

    public BusinessException(Integer code) {
        super(String.valueOf(code));
        this.code = code;
    }

    public BusinessException(String message) {
        super(message);
        this.code = CommonConstants.FAIL;
    }

    public BusinessException(Integer code, String message) {
        super(message);
        this.code = code;
    }

    public BusinessException(BaseErrorInterface baseError) {
        super(baseError.getValue());
        this.code = baseError.getCode();
    }

    public BusinessException(Integer code, Throwable cause) {
        super(String.valueOf(code), cause);
        this.code = code;
    }

    public BusinessException(Integer code, String message, Throwable cause) {
        super(message, cause);
        this.code = code;
    }

    public BusinessException(BaseErrorInterface baseError, Throwable cause) {
        super(baseError.getValue(), cause);
        this.code = baseError.getCode();
    }
}
